package main

import (
	"fmt"
	"time"
)

/*
从一个数组中找出2个数的和是目标数，记录下标返回

 */

//map法
func getSum(nums []int, target int) []int {
	m := map[int]int{}
	for i, v := range nums {
		if k, ok := m[target - v]; ok {
			fmt.Println("__", i, k)
			return []int{i, k}
		}
		m[v] = i
	}
	return nil
}

func main()  {
	nums := []int{1, 7, 2, 3}
	target := 9
	getSum(nums, target)

	fmt.Println("_",TimeNow())
}

func TimeNow() int {
	now := time.Now()
	unix := now.Unix()
	return int(unix)
}